<!--
 * @company : 版权所属 四川北星惯牌科技有限公司
 * @contact : 刘经理 19326416371
 -->
<template>
	<view class="content w100">
		<up-parse :tagStyles="tagStyles" :content="protocolInfo"></up-parse>
		<view class="sign-bnt flex-center" @click="toSign" v-if="pageType === 'match_protocal'">
			<up-icon name="edit-pen-fill" color="#fff" size="28rpx"></up-icon>
			<text class="text">同意并签署当前赛事协议</text>
		</view>
	</view>
</template>

<script setup>
	import {
		configInfoStore
	} from '@/stores/config';
	const {
		configInfo
	} = configInfoStore();
	const matchStore = matchInfoStore();
	const matchInfo = computed(() => matchStore.matchInfo);
	import {
		matchInfoStore
	} from '@/stores/match';
	const tagStyles = {
		p: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
		span: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
		div: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
		h1: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
		h2: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
		h3: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
		h4: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
		h5: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
		h6: "color:#000;font-size:24rpx;line-height:42rpx;word-wrap: break-word;",
	};
	const protocolInfo = ref('<p>未找到相关协议，请重试~</p>');
	const pageType = ref('user_protocal'); //用户协议
	onLoad((option) => {
		if (option.type) {
			const {
				type
			} = option;
			if (type == 1) { //用户协议
				pageType.value = 'user_protocal';
				protocolInfo.value = configInfo[pageType.value]?.value;
				uni.setNavigationBarTitle({
					title: '用户协议'
				});

			} else if (type == 2) { //隐私协议
				pageType.value = 'private_protocal';
				protocolInfo.value = configInfo[pageType.value]?.value;
				uni.setNavigationBarTitle({
					title: '隐私协议'
				});

			} else if (type == 3) { //支付协议
				pageType.value = 'pay_protocal';
				protocolInfo.value = configInfo[pageType.value]?.value;
				uni.setNavigationBarTitle({
					title: '支付协议'
				});

			} else if (type == 4) { //提现协议
				pageType.value = 'withdraw_protocal';
				protocolInfo.value = configInfo[pageType.value]?.value;
				uni.setNavigationBarTitle({
					title: '提现协议'
				});

			} else if (type == 5) { //赛事协议
				pageType.value = 'match_protocal';
				uni.setNavigationBarTitle({
					title: '赛事协议'
				});
				if (matchInfo.value && matchInfo.value.protocol) {
					protocolInfo.value = matchInfo.value.protocol;
					return
				}
				uni.$u.toast('未找到相关协议，请退出重试');

			}
		}
	});
	const toSign = () => { //去签名
		uni.navigateTo({
			url: '/page_activity/views/signature'
		})
	}
</script>
<style>
	page {
		background-color: #fff !important;
	}
</style>
<style lang="scss" scoped>
	.content {
		width: 100vw;
		box-sizing: border-box;
		padding: 24rpx;
		word-wrap: break-word;
		padding-bottom: calc(78rpx + env(safe-area-inset-bottom));
	}

	.sign-bnt {
		width: 100vw;
		position: fixed;
		bottom: 0;
		padding-bottom: env(safe-area-inset-bottom);
		left: 0;
		background-color: #ff9900;
		z-index: 999;

		.text {
			font-size: 24rpx;
			color: #fff;
			margin-left: 12rpx;
		}

		box-shadow: 0 0 10rpx 1rpx rgba(0, 0, 0, .1);
		height: 78rpx;
	}
</style>